#include<sys/types.h>
#include<unistd.h>
#include<fcntl.h>
#include<stdio.h>

void output_tty(int fd)
{
	const char* str = ttyname(fd);
	if (str)
	{
		printf("%d: %s\n",fd,str);
	}
	else 
	{
		printf("%d: have not terminal\n",fd);
	}
}

int main()
{
	output_tty(0);
	output_tty(1);
	output_tty(2);
	int fd = open("/dev/null", O_RDWR);
	output_tty(fd);
	return 0;
}
